package com.mask.im.server.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

/**
 * @author jian
 */
@EnableAsync
@Configuration
public class AsyncConfig {

	@Bean
	public TaskExecutor taskThread(){
		ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
		//核心线程数
		taskExecutor.setCorePoolSize(10);
		//最大线程数
		taskExecutor.setMaxPoolSize(20);
		//最大空闲时间
		taskExecutor.setKeepAliveSeconds(60);
		//阻塞队列长度
		taskExecutor.setQueueCapacity(20);
		//前缀名
		taskExecutor.setThreadNamePrefix("Mask-Thr-");
		return taskExecutor;
	}
}
